//
//  RegisterViewController.m
//  Cheirapsis
//
//  Created by 于  冰 on 15/11/3.
//  Copyright © 2015年 mohe. All rights reserved.
//

#import "RegisterViewController.h"
#import "MBProgressHUD.h"
#import "Define.h"
#import "Request.h"
#import "iToast.h"
#import "BaseUtil.h"

@interface RegisterViewController ()

@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title =@"注册";
    self.view.backgroundColor =ALL233COROL;
    _passWord.secureTextEntry = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)registeBtn:(UIButton *)sender {
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    if (!_phoneText.text.length) {
        [[iToast makeText:@"用户名不能为空！"] show];
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        return;
    }else if (![BaseUtil isMobileNumber:_phoneText.text]){
        [[iToast makeText:@"请输入手机号！"] show];
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        return;
    }else if (!_passWord.text.length){
        [[iToast makeText:@"密码不能为空！"] show];
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        return;
    }else if (!_nickText.text.length){
        [[iToast makeText:@"昵称不能为空！"] show];
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        return;
    }else{
        [[iToast makeText:@"注册成功"] show];
        [[Request sharedInstance] registers:_phoneText.text pw:_passWord.text nick:_nickText.text];
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        [self.navigationController popViewControllerAnimated:YES];
    }
}


@end
